package com.gebogebo.mobile.parking.sdb;

import java.util.List;

import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.simpledb.AmazonSimpleDB;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.model.BatchPutAttributesRequest;
import com.amazonaws.services.simpledb.model.Item;
import com.amazonaws.services.simpledb.model.SelectRequest;


public class SimpleDBClient {
    private static AmazonSimpleDB sdb;
    static {
        sdb = new AmazonSimpleDBClient(new PropertiesCredentials(
        		SimpleDBClient.class.getResourceAsStream("AwsCredentials.properties")));
    }

    public static boolean putData(String domain, List values) {
        sdb.batchPutAttributes(new BatchPutAttributesRequest(domain, values));
        return true;
    }
    
//my changes
    public static List<Item> getData(String domain, String query) {
        System.out.println("Running: " + query + "\n");
        SelectRequest selectRequest = new SelectRequest(query);
        return sdb.select(selectRequest).getItems();
    }
    

 }
